package com.thoughtworks.bytecode2class.instruction;

import java.util.List;

public class INVOKEINTERFACE extends Instruction {

    private int interfaceMethodInfoIndex;
    private int argsCount;

    public INVOKEINTERFACE(List<Byte> bytes, int offset) {
        super(OpCode.INVOKEINTERFACE, bytes, offset);
        parseInterfaceMethodInfoIndex();
        parseArgsCount();
    }

    private void parseInterfaceMethodInfoIndex() {
        interfaceMethodInfoIndex = bytes.get(offset + 1) << 8 | bytes.get(offset + 2);
    }

    private void parseArgsCount() {
        argsCount = bytes.get(offset + 3);
    }


    public int getInterfaceMethodInfoIndex() {
        return interfaceMethodInfoIndex;
    }

    public int getArgsCount() {
        return argsCount;
    }

    @Override
    public String getParameter() {
        return "#" + String.valueOf(interfaceMethodInfoIndex);
    }
}
